<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>国家公路网综合养护管理系统</title>
<block th:replace="commonBase"></block>
<link
	th:href="@{/common/res/third-party/scrollbar/jquery.mCustomScrollbar.css}"
	rel="stylesheet" type="text/css" />
<script
	th:src="@{/common/res/third-party/scrollbar/jquery.mCustomScrollbar.concat.min.js}"
	type="text/javascript"></script>
<link rel="stylesheet"
	th:href="@{/common/js/miniui/res/font-awesome/css/font-awesome.min.css}" />
<link th:href="@{/common/frame/frame1/res/menu/menu.css}"
	rel="stylesheet" type="text/css" />
<script th:src="@{/common/frame/frame1/res/menu/menu.js}"
	type="text/javascript"></script>
<!-- <script th:src="@{/common/frame/frame1/res/menutip.js}"
	type="text/javascript"></script> -->
<link th:href="@{/common/frame/frame1/res/tabs.css}" rel="stylesheet"
	type="text/css" />
<!-- <link th:href="@{/common/frame/frame1/res/frame.css}" rel="stylesheet"
	type="text/css" /> -->
<link th:href="@{/common/frame/frame1/res/index.css}" rel="stylesheet"
	type="text/css" />
<link th:href="@{/common/frame/frame1/res/kz_style.css}"
	rel="stylesheet" type="text/css" />
</head>
<body>
	<div class="container"> 
		<div class="sidebar" style="top:0px;">
			<div class="sidebar-toggle">
				<i class="fa fa-fw fa-dedent"></i>
			</div>
			<div id="mainMenu"></div>
		</div>
		<div class="main" style="top:0px;border-width:5px;border-left-style:solid;border-color:#f7f7f7;">
			<div id="mainTabs" class="mini-tabs main-tabs" activeIndex="0" contextMenu="#tabsMenu"
				style="height: 100%;" plain="false" buttons="#tabsButtons"
				arrowPosition="side">
				<!-- <div name="index" iconCls="fa-android" title="首页">
					<div class="layui-tab-item layui-show"
						style="height: 100%; overflow-y: hidden;">
						<iframe style="margin-left: -8px;" id="contextframe"
							name="iframe0" width="100%" height="100%" th:src="@{/appli}"
							frameborder="0"></iframe>
					</div>
				</div> -->
			</div>
			
			<ul id="tabsMenu" class="mini-contextmenu" onbeforeopen="onBeforeOpen">        
		        <li onclick="closeTab">关闭标签页</li>                
			    <li onclick="closeAllBut">关闭其他标签页</li>
			    <li onclick="closeAll">关闭所有标签页</li>        
		       <!--  <li onclick="closeAllButFirst">关闭其他[首页除外]</li>   --> 
		    </ul>
			
			<!-- <div id="tabsButtons">
					<a class="tabsBtn" title="关闭其他"  href="javascript:void(0);" onclick="closeTab()"><i class="fa fa-remove"></i></a> 
			</div> -->
		</div>
	</div>
	<script th:inline="javascript" type="text/javascript">
 /*<![CDATA[*/
 
 		mini.parse();
 		var tabs = mini.get("mainTabs");
        var currentTab = null;

        function onBeforeOpen(e) {
            currentTab = tabs.getTabByEvent(e.htmlEvent);
            if (!currentTab) {
                e.cancel = true;                
            }
        }

        ///////////////////////////
        function closeTab() {
            tabs.removeTab(currentTab);
        }
        function closeAllBut() {
            tabs.removeAll(currentTab);
        }
        function closeAll() {
            tabs.removeAll();
        }
        function closeAllButFirst() {
            var but = [currentTab];            
            but.push(tabs.getTab("index"));
            tabs.removeAll(but);
        }
 
    function activeTab(item) {
        
        var tab = tabs.getTab(item.id);
        if (!tab) {
            tab = { name: item.id, title: item.text, url: item.url, iconCls: item.iconCls, showCloseButton: true };
            tab = tabs.addTab(tab);
        }
        tabs.activeTab(tab);
    }

    function closeTab(){
	   	 var tabs = mini.get("mainTabs");
	   	 var tab = tabs.getActiveTab();
	   	 tabs.removeAll(tab); 
    }

    var cotextRoot = /*[[@{/}]]*/
    var menu = null;
    $(function () {
    	 var menu = new Menu("#mainMenu", {
             itemclick: function (item) {
                 if (!item.children) {
                     activeTab(item);
                 }
             }
         });

         $(".sidebar").mCustomScrollbar({ autoHideScrollbar: true });
         
         var sysId = /*[[${sysId}]]*/
                
        if(null != sysId && ''!=sysId){
            $.ajax({
    	    	type: 'POST',
    	    	async: true,
    	        url: basePath+"module/menulist?systemId="+sysId,
    	        success: function (reptext) {
    		        	var childText = getJsonTree(reptext,sysId);
    		        	var treetext = JSON.stringify(childText);
    		        	var reg =new RegExp(',"children":[\[\]]',"g"); //兼容IE
// 						if(!$.browser.msie) { 
// 							reg =new RegExp(/,"children":\[\]/,"g");//兼容chrome
// 						} 
    		        	treetext = treetext.replace(reg,"")
    		            var data = mini.decode(treetext);
    		            menu.loadData(data);
    		            menu.expand();//展开节点
    		    }
    	    }) 
         }
         
         
        //toggle
        $("#toggle, .sidebar-toggle").click(function () {
            $('body').toggleClass('compact');
            mini.layout();
        });

        //dropdown
        $(".dropdown-toggle").click(function (event) {
            $(this).parent().addClass("open");
            return false;
        });

        $(document).click(function (event) {
            $(".dropdown").removeClass("open");
        });
      
    });

	/**
	*生成tree满足的json数据
	**/
    function getJsonTree(reptext,parentId){
        var itemArr=[];
        var data  = JSON.parse(reptext);
         for(var i=0;i<data.length;i++){ 
            var node=data[i];
             if(node.pid==parentId){ 
                 if(!node.iconCls){
                	 node.iconCls = 'fa fa-list-alt';
                  }
                var newNode={id:node.id,iconCls:node.iconCls,text:node.text,url:node.url,children:getJsonTree(reptext,node.id)};
                itemArr.push(newNode);              
             }
        }
        return itemArr;
    }

/*]]>*/
</script>
</body>
</html>